﻿@using Microsoft.AspNetCore.Http.Features
@model Hybrid.AspNetCore.Mvc.Models.TopBarLanguageSwitchViewModel

@{
    var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
    bool showBanner = !consentFeature?.CanTrack ?? false;
}

@if (Model.Languages.Any() && !showBanner)
{
    <li class="dropdown">
        <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button">
            <i class="@Model.CurrentLanguage.Icon" title="@Model.CurrentLanguage.DisplayName"></i>
            <span>@Model.CurrentLanguage.DisplayName</span>
            <b class="caret"></b>
            <input type="hidden" id="locale" value="@Model.CurrentLanguage.Name" />
        </a>

        <ul class="dropdown-menu pull-right">
            @foreach (LanguageInfo language in Model.Languages)
            {
                if (language.Name != Model.CurrentLanguage.Name)
                {
                    <li><a href="@(ApplicationPath)Localization/ChangeCulture?cultureName=@(language.Name)&returnUrl=@(Context.Request.Path + Context.Request.QueryString.Value)"><i class="@language.Icon"></i> @language.DisplayName</a></li>
                }
            }
        </ul>
    </li>
}